package com.young4j.springdemo.domain;

import java.util.List;

/**
 * 
 * @param <T>
 */
public class PageBean<T> {

    private List<T> list;
    private Integer page;
    private Integer size;
    private Long total;

    public long getPageCount() {
        if (this.total % this.size == 0) {
            return this.total / this.size;
        }
        return this.total / this.size + 1;
    }

    public PageBean(List<T> list, Long total, Integer page, Integer size) {
        this.list = list;
        this.total = total;
        this.page = page;
        this.size = size;
    }

    public PageBean() {
    }

    public boolean isFirst() {
        return (this.page.intValue() == 1) || (this.total.intValue() == 0);
    }

    public boolean isLast() {
        return (this.total.intValue() == 0) || (this.page.intValue() >= getPageCount());
    }

    public boolean isHasNext() {
        return this.page.intValue() < getPageCount();
    }

    public boolean isHasPrev() {
        return this.page.intValue() > 1;
    }

    public List<T> getList() {
        return this.list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public Integer getPage() {
        return this.page;
    }

    public void setPage(Integer page) {
        this.page = page;
    }

    public Integer getSize() {
        return this.size;
    }

    public void setSize(Integer size) {
        this.size = size;
    }

    public Long getTotal() {
        return this.total;
    }

    public void setTotal(Long total) {
        this.total = total;
    }
}
